import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import { Divider, Form, Field, NavBar, Button, Tabbar, TabbarItem, Icon, Tab, Tabs, Cell, List, PullRefresh, ActionSheet, Popup, Row, Col, Badge, Search, Tag, CellGroup, Image, Dialog, DatetimePicker, Loading } from 'vant'
import directives from './utils/directives'
import fofo from './utils/fofo.js'
// 引入移动端适配插件
import 'amfe-flexible'
import hljs from 'highlight.js' // hljs对象
import 'highlight.js/styles/default.css' // 代码高亮的样式
// 测试接口
import { textApi } from './api'
// 路由首位
import '@/utils/permit.js'

Vue.use(DatetimePicker)
Vue.use(Dialog)

Vue.use(Loading)
Vue.use(Image)

Vue.use(CellGroup)
Vue.use(Tag)
Vue.use(fofo)
Vue.use(Divider)
Vue.use(directives)
Vue.use(Search)

Vue.use(Badge)
Vue.use(Row)
Vue.use(Col)

Vue.use(Popup)

Vue.use(ActionSheet)

Vue.use(PullRefresh)

Vue.use(List)

Vue.use(Cell)

Vue.use(Tab)
Vue.use(Tabs)
Vue.use(Tabbar)
Vue.use(Icon)
Vue.use(TabbarItem)
Vue.use(Button)
Vue.use(Form)
Vue.use(Field)
Vue.use(NavBar)
Vue.config.productionTip = false
Vue.directive('highlight', function (el) { // 自定义一个代码高亮指令
  const highlight = el.querySelectorAll('pre, code') // 获取里面所有pre或者code标签
  highlight.forEach((block) => {
    hljs.highlightElement(block) // 突出显示这些标签(以及内部代码, 会自动识别语言)
  })
})

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
const myFn = async () => {
  // 捕获错误
  try {
    // 可能正确的代码
    await textApi()
  } catch (err) {
    // 如果错误就打印错误
    console.dir(err)
  }
}
myFn()
